package com.hejielife.guardedsuspension1;

import java.util.LinkedList;

/**
 * 2019年8月2日 上午11:14:59
 * 
 * @author hejielife
 * @despribe 请求队列
 */
public class RequestQueue {
	private final LinkedList queue = new LinkedList();

	public synchronized Request getRequest() {
		while (queue.size() <= 0) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		return (Request) queue.removeFirst();
	}

	public synchronized void putRequest(Request request) {
		queue.addLast(request);
		notifyAll();
	}
}
